package cc.risingsun.wing.ds;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;

import cc.risingsun.wing.util.CollectionUtils;
import cc.risingsun.wing.util.LinkedMultiValueMap;
import cc.risingsun.wing.util.MultiValueMap;

/**
 * 数据结构封装类,框架中所有的数据结构都是通过这个类的静态方法产生的
 * 
 * @author iron.yin@gmail.com
 */
public final class DataStruct {

	public static <E> Set<E> hashSet() {
		return new HashSet<E>();
	}

	public static <E> Set<E> singleton(E e) {
		return Collections.singleton(e);
	}

	public static <E> Set<E> hashSet(int initialCapacity) {
		return new HashSet<E>(initialCapacity);
	}

	public static <E> Set<E> hashSet(int initialCapacity, float factor) {
		return new HashSet<E>(initialCapacity, factor);
	}

	public static <E> Set<E> hashSet(Collection<? extends E> c) {
		return new HashSet<E>(c);
	}

	public static <E> Set<E> linkedHashSet() {
		return new LinkedHashSet<E>();
	}

	public static <E> Set<E> linkedHashSet(int initialCapacity) {
		return new LinkedHashSet<E>(initialCapacity);
	}

	public static <E> Set<E> linkedHashSet(int initialCapacity, float factor) {
		return new LinkedHashSet<E>(initialCapacity, factor);
	}

	public static <E> Set<E> linkedHashSet(Collection<? extends E> c) {
		return new LinkedHashSet<E>(c);
	}

	public static <K, V> Map<K, V> hashMap() {
		return new HashMap<K, V>();
	}

	public static <K, V> Map<K, V> hashMap(int initialCapacity) {
		return new HashMap<K, V>(initialCapacity);
	}

	public static <K, V> Map<K, V> hashMap(int initialCapacity, float factor) {
		return new HashMap<K, V>(initialCapacity, factor);
	}

	public static <K, V> Map<K, V> hashMap(Map<? extends K, ? extends V> map) {
		return new HashMap<K, V>(map);
	}

	public static <K, V> ConcurrentMap<K, V> concurrencyHashMap() {
		return new ConcurrentHashMap<K, V>();
	}

	public static <K, V> ConcurrentMap<K, V> concurrencyHashMap(
			int initialCapacity) {
		return new ConcurrentHashMap<K, V>(initialCapacity);
	}

	public static <K, V> ConcurrentMap<K, V> concurrencyHashMap(
			int initialCapacity, float factor) {
		return new ConcurrentHashMap<K, V>(initialCapacity, factor);
	}

	public static <K, V> ConcurrentMap<K, V> concurrencyHashMap(
			int initialCapacity, float factor, int concurrencyLevel) {
		return new ConcurrentHashMap<K, V>(initialCapacity, factor, concurrencyLevel);
	}

	public static <K, V> ConcurrentMap<K, V> concurrencyHashMap(
			Map<? extends K, ? extends V> map) {
		return new ConcurrentHashMap<K, V>(map);
	}
	
	public static <K,V> MultiValueMap<K, V> multiValueMap(){
		return new LinkedMultiValueMap<K, V>();
	}
	
	public static <K,V> MultiValueMap<K, V> multiValueMap(int initialCapacity){
		return new LinkedMultiValueMap<K, V>(initialCapacity);
	}
	
	public static <K,V> MultiValueMap<K, V> multiValueMap(Map<K, List<V>> otherMap){
		return new LinkedMultiValueMap<K, V>(otherMap);
	}

	public static <E> Queue<E> concurrencyLinkQueue() {
		return new ConcurrentLinkedQueue<E>();
	}

	public static <E> Queue<E> concurrencyLinkQueue(Collection<? extends E> c) {
		return new ConcurrentLinkedQueue<E>(c);
	}

	public static <E> List<E> arrayList() {
		return new ArrayList<E>();
	}

	public static <E> List<E> arrayList(int initialCapacity) {
		return new ArrayList<E>(initialCapacity);
	}

	public static <E> List<E> arrayList(Collection<? extends E> c) {
		return new ArrayList<E>(c);
	}

}
